<template>
  <div style="position: relative">
    <div class="content">
      <div class="info">
        <div class="title">基本信息</div>
        <div class="list">
          <div class="item">
            <div class="tit">创建时间</div>
            <div class="desc">
              {{ detailList.gmtCreated ? detailList.gmtCreated : "-" }}
            </div>
          </div>
          <div class="item" v-if="detailType == '1'">
            <div class="tit">商户订单号</div>
            <div class="desc">
              {{ detailList.transferNo ? detailList.transferNo : "-" }}
            </div>
            <div
              v-if="detailList.transferNo"
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            >
              <i
                class="el-icon-document-copy"
                @click="copyAppId(detailList.transferNo)"
              ></i>
            </div>
          </div>
          <div class="item" v-if="detailType == '1'">
            <div class="tit">云尘付流水号</div>
            <div class="desc">
              {{ detailList.orderNo ? detailList.orderNo : "-" }}
            </div>
            <div
              v-if="detailList.orderNo"
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            >
              <i
                class="el-icon-document-copy"
                @click="copyAppId(detailList.orderNo)"
              ></i>
            </div>
          </div>
          <div class="item" v-if="detailType == '2'">
            <div class="tit">批次号</div>
            <div class="desc">
              {{ detailList.merBatchNo ? detailList.merBatchNo : "-" }}
            </div>
            <div
              v-if="detailList.merBatchNo"
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            >
              <i
                class="el-icon-document-copy"
                @click="copyAppId(detailList.merBatchNo)"
              ></i>
            </div>
          </div>
          <div class="item">
            <div class="tit">付款方</div>
            <div class="desc">
              {{
                detailType == "1"
                  ? detailList.outMemberName
                    ? detailList.outMemberName
                    : "-"
                  : detailList.memberName
                  ? detailList.memberName
                  : "-"
              }}
            </div>
          </div>
          <div class="item" v-if="detailType == '1'">
            <div class="tit">付款金额/元</div>
            <div class="desc">
              {{ detailList.fmtTransAmt ? detailList.fmtTransAmt : "-" }}
            </div>
          </div>
          <div class="item" v-if="detailType == '2'">
            <div class="tit">付款总金额/元</div>
            <div class="desc">
              {{ detailList.fmtTotalAmount ? detailList.fmtTotalAmount : "-" }}
            </div>
          </div>
          <!-- <div class="item">
            <div class="tit">渠道手续费/元</div>
            <div class="desc">
              {{ detailList.fmtFeeAmt ? detailList.fmtFeeAmt : "-" }}
            </div>
          </div> -->

          <div class="item">
            <div class="tit">支付时间</div>
            <div class="desc">
              {{
                detailType == "1"
                  ? detailList.gmtModified
                    ? detailList.gmtModified
                    : "-"
                  : detailList.gmtCreated
                  ? detailList.gmtCreated
                  : "-"
              }}
            </div>
          </div>
          <div class="item">
            <div class="tit">付款渠道</div>
            <div class="desc" v-if="detailType == '1'">
              {{
                detailList.payformChannel == "ada"
                  ? "汇付"
                  : detailList.payformChannel == "wechat"
                  ? "微信"
                  : "支付宝"
              }}
            </div>
            <div class="desc" v-else>
              {{
                detailList.channel == "ada"
                  ? "汇付"
                  : detailList.channel == "wechat"
                  ? "微信"
                  : "支付宝"
              }}
            </div>
          </div>
          <div class="item">
            <div class="tit">{{detailType == '1' ? '付款状态':'结果'}}</div>
            <div class="desc">
              {{
                detailType == "1"
                  ? setAuditStatus(detailList.status).str
                  : setAuditStatus1(detailList.status).str
              }}
            </div>
          </div>
          <div class="item" v-if="detailList.status == 'fail'">
            <div class="tit">失败原因</div>
            <div class="desc">
              {{ detailList.errorMsg ? detailList.errorMsg : "-" }}
            </div>
          </div>
        </div>
      </div>
      <div class="info" v-if="this.$route.query.type == 1 ? true : false">
        <div class="title">收款方信息</div>
        <div class="list">
          <div class="item">
            <div class="tit">是否多个收款方</div>
            <div class="desc">否</div>
          </div>
          <div class="item">
            <div class="tit">收款方</div>
            <div class="desc">
              {{ detailList.inAccountName ? detailList.inAccountName : "-" }}
            </div>
          </div>
          <div class="item">
            <div class="tit">{{detailList.payformChannel == "ada"
                  ? "用户ID"
                  : detailList.payformChannel == "wechat"
                  ? "OpenID"
                  : "支付宝账号" }}</div>
            <div class="desc">
              {{ detailList.inMemberNo ? detailList.inMemberNo : "-" }}
            </div>
          </div>
          <div class="item">
            <div class="tit">转账名称</div>
            <div class="desc">
              {{ detailList.goodsTitle ? detailList.goodsTitle : "-" }}
            </div>
          </div>
          <div class="item">
            <div class="tit">备注</div>
            <div class="desc">
              {{ detailList.remark ? detailList.remark : "-" }}
            </div>
          </div>
        </div>
      </div>
      <div class="info" v-else style="min-width: 800px">
        <div class="title">收款方信息</div>
        <div class="list" style="position: relative">
          <div class="item">
            <div class="tit">是否多个收款方</div>
            <div class="desc">是</div>
          </div>
          <div
            style="
              position: absolute;
              right: 0;
              top: 10px;
              color: #03bfc6;
              cursor: pointer;
            "
            @click="openShow = !openShow"
          >
            {{ openShow ? "收起" : "展开" }}
          </div>
        </div>
        <div style="margin-top: 20px" v-if="openShow">
          <tr class="openBox">
            <td>{{
                detailList.channel == "ada"
                  ? "用户ID"
                  : detailList.channel == "wechat"
                  ? "OpenID"
                  : "支付宝账号"
              }}</td>
            <td>收款方</td>
            <td>付款金额/元</td>
            <td>备注</td>
            <td>商户流水号</td>
            <td>状态</td>
          </tr>
          <div
            class="openBox1"
            v-for="(o, oIndex) in detailList.settleBalancePayList"
            :key="oIndex"
          >
            <td>
              {{ o.inMemberNo }}
            </td>
            <td>
              {{ o.inAccountName }}
            </td>
            <td>
              {{ o.fmtTransAmt }}
            </td>
            <td>
              {{ o.remark }}
            </td>
            <td>
              {{ o.transferNo }}
            </td>
            <td>
              {{ setAuditStatus2(o.status).str }}
            </td>
          </div>
        </div>
      </div>
    </div>
    <div class="back" @click="backFn">
      <i class="el-icon-close"></i>
    </div>
    <div class="left">
      <el-breadcrumb separator=">" style="margin-bottom: 20px">
        <el-breadcrumb-item v-for="item of breadList" :key="item">{{
          item
        }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
  </div>
</template>
<script>
export default {
  name: "dealSearchDetail",
  components: {},
  data() {
    return {
      detailType: "1",
      detailList: {},
      openShow: false,
      breadList: [],
    };
  },
  created() {
    this.breadList = this.$route.meta.title;
    let id = this.$route.query.id;
    let type = this.$route.query.type;
    this.detailType = type;
    if (id) {
      if (type == "1") {
        this.$http
          .get(`/api/merchant/settleBalancePay/get?id=${id}`)
          .then((res) => {
            if (res.code === "0000") {
              //console.log(res.data);
              this.detailList = res.data;
            }
          });
      } else {
        this.$http
          .get(`/api/merchant/settleBalancePay/searchBatchById?id=${id}`)
          .then((res) => {
            if (res.code === "0000") {
              //console.log(res.data);
              this.detailList = res.data;
            }
          });
      }
    }
  },
  methods: {
    setAuditStatus2(val) {
      let color = "";
      let str = "";
      switch (val) {
        case "processing":
          str = "处理中";
          color = "pedding";
          break;
        case "success":
          str = "处理成功";
          color = "succeed";
          break;
        case "fail":
          str = "处理失败";
          color = "failed";
          break;
        // case "1":
        //   str = "待发送";
        //   color = "pedding";
        //   break;
        // case "2":
        //   str = "已取消";
        //   color = "";
        //   break;
        // case "3":
        //   str = "已退票";
        //   color = "";
        // break;
        default:
          break;
      }
      return {
        str,
        color,
      };
    },
    setAuditStatus(val) {
      let color = "";
      let str = "";
      switch (val) {
        case "processing":
          str = "处理中";
          color = "pedding";
          break;
        case "success":
          str = "处理成功";
          color = "succeed";
          break;
        case "fail":
          str = "处理失败";
          color = "failed";
          break;
        // case "1":
        //   str = "待发送";
        //   color = "pedding";
        //   break;
        // case "2":
        //   str = "已取消";
        //   color = "";
        //   break;
        // case "3":
        //   str = "已退票";
        //   color = "";
        // break;
        default:
          break;
      }
      return {
        str,
        color,
      };
    },
    setAuditStatus1(val) {
      let color = "";
      let str = "";
      switch (val) {
        case "applying":
          str = "申请中";
          color = "pedding";
          break;
        case "applied":
          str = "申请成功";
          color = "succeed";
          break;
        case "applyFail":
          str = "申请失败";
          color = "failed";
          break;
        case "all_fail":
          str = "失败";
          color = "failed";
          break;
          case "all_sucess":
          str = "成功";
          color = "succeed";
          break;
          case "part_sucess":
          str = "部分成功";
          color = "succeed";
          break;
      }
      return {
        str,
        color,
      };
    },
    backFn() {
      this.$backTo(`/merchant/dealSearch`);
    },
    copyAppId(value) {
      const input = document.createElement("input"); // 创建input对象
      input.value = value; // 设置复制内容
      document.body.appendChild(input); // 添加临时实例
      input.select(); // 选择实例内容
      document.execCommand("Copy"); // 执行复制
      document.body.removeChild(input); // 删除临时实例
      this.$message.success("复制成功！");
    },
  },
};
</script>
<style scoped lang="scss">
.content {
  min-height: 780px;
  padding: 160px 100px;
  display: flex;
  justify-content: start;
  flex-wrap: wrap;
  .info {
    width: 33.3%;
    min-width: 500px;
    margin-bottom: 40px;
    padding: 0 2%;
    .title {
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #1d1c1c;
      padding-bottom: 15px;
      border-bottom: 1px solid #03bfc6;
    }
    .list {
      margin-top: 35px;
      .item {
        display: flex;
        .tit {
          min-width: 100px;
          margin-right: 32px;
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #869daa;
          line-height: 40px;
          text-align: right;
        }
        .desc {
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #1d1c1c;
          line-height: 40px;
          overflow: hidden;
          word-wrap: break-word;
        }
      }
    }
    .openBox {
      margin-bottom: 20px;
      height: 22px;
      font-size: 15px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 600;
      color: #1d1c1c;
      line-height: 22px;
      display: flex;
      justify-content: start;
      td {
        display: inline-block;
        min-width: 19%;
        padding: 0 40px 0 0;
      }
    }
    .openBox1 {
      margin-bottom: 20px;
      height: 22px;
      font-size: 14px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 400;
      color: #1d1c1c;
      line-height: 22px;
      display: flex;
      justify-content: start;
      text-align: left;
      td {
        padding: 0 40px 0 0;
        min-width: 19%;
        width: 1px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
  }
}
.back {
  position: absolute;
  right: 55px;
  top: 20px;
  font-size: 20px;
  cursor: pointer;
}
.left {
  position: absolute;
  left: 55px;
  top: 31px;
  height: 20px;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #869daa;
  line-height: 20px;
}
// :deep(.el-table__expand-icon) {
//   // position: absolute;
//   // left:140px;
//   float: left;
// }
@media screen and (max-width: 1770px) {
  .content {
    .info {
      box-sizing: content-box !important;
      width: 33.3%;
      min-width: 520px;
      margin-bottom: 40px;
      padding: 0 5.5%;
    }
  }
}

@media screen and (max-width: 1550px) {
  .content {
    .info {
      box-sizing: content-box !important;
      width: 33.3%;
      min-width: 488px;
      margin-bottom: 40px;
      padding: 0 2%;
    }
  }
}
</style>
